import React, { Component } from "react";

/* 
  事件传参
  1. bind 
  2.箭头函数
  3.data属性传
https://zh-hans.reactjs.org/docs/handling-events.html
*/
class App extends Component {
  // handleClick = (params, e) => {
  //   console.log(params, e);
  // };
  handleClick = (e) => {
    console.log(e);
    console.log(e.currentTarget.dataset["index"]);
  };
  render() {
    return (
      <div>
        {/* bind */}
        {/* <button onClick={this.handleClick.bind(this,"🐂")}>传参</button> */}
        {/* 箭头函数 */}
        {/* <button
          onClick={(e) => {
            this.handleClick("牛", e);
          }}
        >
          传参
        </button> */}
        <button data-index={"🐂"} onClick={this.handleClick}>
          传参
        </button>
      </div>
    );
  }
}

export default App;
